﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


public class ListNodeLemon
{


   public int val;
    public ListNodeLemon next;
    public ListNodeLemon(int val=0, ListNodeLemon next=null)
    {
        this.val = val;
        this.next = next;
    }

}


public class ProgramLemon1
{
    public static void MainLemon1()
    //public static void Main()
    {
        //先读取输入创建链表
        string line;
     

        ListNodeLemon head = new ListNodeLemon(-1);
        ListNodeLemon cur = head;


        int ans = 0;
        line = Console.ReadLine();
        
        // 注意，如果输入是多个测试用例，请通过while循环处理多个测试用例
            string[] tokens = line.Split();
           
            for (int j = 0; j < tokens.Length; j++)
            {
                ans = int.Parse(tokens[j]);
                //ans加入链表
                cur.next = new ListNodeLemon(ans);
                cur = cur.next;


            }
       

    


        SolLemon1 solLemon1 = new ();
        ListNodeLemon res= solLemon1.exchange(head.next);

        while (res != null)
        {
            Console.Write(res.val+" ");
            res = res.next;
        }

    }
}


public class SolLemon1
{
    public ListNodeLemon exchange(ListNodeLemon head)
    {

        if(head.val == -1 || head.next.val == -1)
        {
            return head.next;
        }
        ListNodeLemon dummyhead = new ListNodeLemon(-2);//虚拟节点
        dummyhead.next= head;

        ListNodeLemon pre = dummyhead;
        ListNodeLemon cur = pre.next;
        ListNodeLemon next = pre;
       
        while(cur.val != -1&& cur.next.val != -1)
        {
            next = cur.next;
            cur.next = next.next;
            next.next = cur;
            pre.next = next;
            pre = cur;
            cur = pre.next;

        }
        if(cur.val == -1)
        {
            pre.next = null;
        }
        else
        {
            cur.next = null;

        }


        return dummyhead.next ;

    }


}


